# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Mathieu Clabaut <mathieu.clabaut@gmail.com>
# Contributor: Artyom Smirnov <smirnoffjr@gmail.com>
# Contributor: Alexis Robert <alexis.robert@gmail.com>
# Contributor: Daniel Nagy <danielnagy@gmx.de>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - configure with --disable-abiflags
#  - patch to build with environment's CFLAGS

pkgname=libantlr3c
pkgver=3.5.2
pkgrel=4
pkgdesc='ANother Tool for Language Recognition'
url='https://www.antlr3.org'
arch=(x86_64)
license=(BSD)
makedepends=(git)
source=("git+https://github.com/antlr/antlr3.git#tag=$pkgver"
        antlr-c-3.3-cflags.patch)
md5sums=('SKIP'
         'f936f142053c03ec57a0be95b7b8fe0c')

prepare() {
  cd antlr3/runtime/C
  patch -p1 -i ${srcdir}/antlr-c-3.3-cflags.patch
  cat <<EOF> antlr3config.h.in
#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <antlr3defs.h>
EOF
  aclocal
  libtoolize
  automake --add-missing
  autoconf
}

build() {
  cd antlr3/runtime/C

  [[ $CARCH =~ arm.* ]] && _cfgopt=--disable-abiflags
  ./configure --prefix=/usr --sysconfdir=/etc ${_cfgopt}
  make
}

package() {
  cd antlr3/runtime/C

  DESTDIR="$pkgdir" make install
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}

# getver: antlr3.org
# vim: ts=2 sw=2 et:
